import request from '../utils/request';

function setUrlParam(data) {
  let _str = '';
  for (let i in data) {
    if (!isNull(data[i])) {
      _str += i + '=' + encodeURIComponent(data[i]) + '&';
    }
  }
  return '?' + _str.substring(0, _str.length - 1);
}

function isNull(e) { // 排除为0 或者其他情况
  let _ = String(e);
  return (_ === 'null' || _ === 'NaN' || _ === 'undefined' || _.length === 0);
}

const api = {
  login(query) { //登录
    return request({
      url: '/account/open/login',
      data: query,
      method: 'POST',
    })
  },




  listReplenishment(query) { //角色列表
    return request({
      url: '/replenishment/open/listReplenishment' + setUrlParam(query),
      method: 'GET',
    })
  },

  orderItemProductionRecordForUpdate(query) { //角色列表
    return request({
      url: '/productionRecord/orderItemProductionRecordForUpdate' + setUrlParam(query),
      method: 'GET',
      ContentType: 'application/json'
    })
  },

  paramRetry(query) { //创建角色
    return request({
      url: '/insideOrder/paramRetry',
      method: 'POST',
      data: query,
    })
  },

  adminRolePageList(query) { //角色列表
    return request({
      url: '/role/page' + setUrlParam(query),
      method: 'GET',
      ContentType: 'application/json'
    })
  },
  createRole(query) { //创建角色
    return request({
      url: '/role/add',
      method: 'POST',
      data: query,
    })
  },
  updateRole(query) { //编辑角色
    return request({
      url: '/role/update',
      method: 'POST',
      data: query,
    })
  },
  deleteRole(query) { //删除角色
    return request({
      url: '/role/delete' + setUrlParam(query),
      method: 'GET',
    })
  },
  saveRoleResource(query) { //保存角色资源
    return request({
      url: '/menuRole/add',
      method: 'POST',
      data: query,
      ContentType: 'application/json'
    })
  },
  roleResourceByRoleName(query) { //获取角色资源
    return request({
      url: '/menuRole/list' + setUrlParam(query),
      method: 'GET',
    })
  },
  userPageList(query) { //人员列表
    return request({
      url: '/account/page' + setUrlParam(query),
      method: 'GET',
    })
  },
  getRoleList(query) { //所有人员
    return request({
      url: '/role/list',
      method: 'GET',
    })
  },
  updateUser(query) { //更新用户
    return request({
      url: '/account/update',
      method: 'POST',
      data: query,
    })
  },

  updatePassword(query) { //所有人员
    return request({
      url: '/account/updatePassword',
      method: 'POST',
      data: query,
    })
  },

  createUser(query) { //创建用户
    return request({
      url: '/account/add',
      data: query,
      method: 'POST',
    })
  },
  deleteAccount(query) { //删除
    return request({
      url: '/account/delete' + setUrlParam(query),
      method: 'GET',
    })
  },
  getStaffPage(query) {
    return request({
      url: '/staff/page' + setUrlParam(query),
      method: 'GET',
    })
  },


  addStaff(query) { //创建员工
    return request({
      url: '/staff/add',
      data: query,
      method: 'POST',
    })
  },
  updateStaff(query) { //编辑员工
    return request({
      url: '/staff/update',
      data: query,
      method: 'POST',
    })
  },
  deleteStaff(query) { //删除
    return request({
      url: '/staff/delete' + setUrlParam(query),
      method: 'GET',
    })
  },
  importStaff(query) { //导入
    return request({
      url: '/staff/Import' + setUrlParam(query),
      method: 'GET',
    })
  },
  getWorkDonePage(query) { //
    return request({
      url: '/workDone/page' + setUrlParam(query),
      method: 'GET',
    })
  },
  importWorkDone(query) { //导入
    return request({
      url: '/workDone/add' + setUrlParam(query),
      method: 'GET',
    })
  },
  deleteWorkDone(query) { //删除
    return request({
      url: '/workDone/delete' + setUrlParam(query),
      method: 'GET',
    })
  },
  getListProduction() { //删除
    return request({
      url: '/workDone/listProduction',
      method: 'GET',
    })
  },
  getListStaffProductionRecord(query) { //删除
    return request({
      url: '/workDone/listStaffProductionRecord' + setUrlParam(query),
      method: 'GET',
    })
  },
  getInsideOrderList(query) { //删除
    return request({
      url: '/insideOrder/page' + setUrlParam(query),
      method: 'GET',
    })
  },
  getInsideOrderDetail(query) {
    return request({
      url: '/insideOrder/insideOrderDetail' + setUrlParam(query),
      method: 'GET',
    })
  },
  updateForBusiness(query) {
    return request({
      url: '/insideOrder/updateForBusiness',
      data: query,
      method: 'POST',
    })
  },
  updateForTechnology(query) {
    return request({
      url: '/insideOrder/updateForTechnology',
      data: query,
      method: 'POST',
    })
  },
  updateForQc(query) {
    return request({
      url: '/insideOrder/updateForQc',
      data: query,
      method: 'POST',
    })
  },
  updateForPlain(query) {
    return request({
      url: '/insideOrder/updateForPlain',
      data: query,
      method: 'POST',
    })
  },

  updateForRequirement2(query) {
    return request({
      url: '/insideOrder/updateForRequirement2',
      data: query,
      method: 'POST',
    })
  },

  updateOrderItem(query) {
    return request({
      url: '/insideOrder/updateOrderItem',
      data: query,
      method: 'POST',
    })
  },





  importParameter(query) {
    return request({
      url: '/insideOrder/parameter' + setUrlParam(query),
      method: 'GET',
    })
  },
  importOrderAdd(query) {
    return request({
      url: '/insideOrder/add',
      data: query,
      method: 'POST',
    })
  },
  insideOrderCheck(query) {
    return request({
      url: '/insideOrder/check',
      data: query,
      method: 'POST',
    })
  },
  importExport(query) {
    return request({
      url: '/insideOrder/export' + setUrlParam(query),
      method: 'GET',
    })
  },
  insideOrderDelete(query) {
    return request({
      url: '/insideOrder/remove' + setUrlParam(query),
      method: 'GET',
    })
  },
  replenishmentAdd(query) {
    return request({
      url: '/replenishment/add',
      data: query,
      method: 'POST',
    })
  },
  replenishmentPage(query) {
    return request({
      url: '/replenishment/page' + setUrlParam(query),
      method: 'GET',
    })
  },
  replenishmentCheck(query) {
    return request({
      url: '/replenishment/check',
      data: query,
      method: 'POST',
    })
  },
  orderNoAndSpecs(query) { // 查询订单的流转信息
    return request({
      url: '/insideOrder/open/orderNoAndSpecs' + setUrlParam(query),
      method: 'GET',
    })
  },


  orderNoAndNumber(query) { // 查询订单的流转信息
    return request({
      url: '/insideOrder/open/orderNoAndNumber' + setUrlParam(query),
      method: 'GET',
    })
  },

  parameterUpAndDown(query) { // 查询订单的流转信息
    return request({
      url: '/insideOrder/open/parameterUpAndDown' + setUrlParam(query),
      method: 'GET',
    })
  },
  subNum(query) { // 查询订单的流转信息
    return request({
      url: '/productionRecord/open/subNum' + setUrlParam(query),
      method: 'GET',
    })
  },




  orderProductionRecord(query) { // 查询订单的流转信息
    return request({
      url: '/productionRecord/open/orderProductionRecord' + setUrlParam(query),
      method: 'GET',
    })
  },


  ordersProductionRecord(query) { // 查询订单的流转信息
    return request({
      url: '/productionRecord/open/ordersProductionRecord' + setUrlParam(query),
      method: 'GET',
    })
  },


  queryReplenishmentParams(query) { // 查询订单的流转信息
    return request({
      url: '/replenishment/open/queryReplenishmentParams' + setUrlParam(query),
      method: 'GET',
    })
  },

  addList(query) { // 批量补料申请
    return request({
      url: '/replenishment/open/addList',
      data: query,
      method: 'POST',
    })
  },
  

  queryOrderProductionRecord(query) { // 查询订单的流转信息
    return request({
      url: '/productionRecord/queryOne' + setUrlParam(query),
      method: 'GET',
    })
  },



  listStaffProductionRecord(query) { // 查询订单的流转信息
    return request({
      url: '/workDone/listStaffProductionRecord' + setUrlParam(query),
      method: 'GET',
    })
  },





  productionRecordBack(query) { // 退回
    return request({
      url: '/productionRecord/back' + setUrlParam(query),
      method: 'GET',
    })
  },


  productionRecordBackForUpdate(query) { // 退回
    return request({
      url: '/productionRecord/open/backForUpdate' + setUrlParam(query),
      method: 'GET',
    })
  },
  orderItemProductionRecord(query) { // 查询订单某个产品的流转信息
    return request({
      url: '/productionRecord/orderItemProductionRecord' + setUrlParam(query),
      method: 'GET',
    })
  },
  orderItemProductionInfo(query) { // 查询订单某个产品的流转信息
    return request({
      url: '/productionRecord/orderItemProductionInfo' + setUrlParam(query),
      method: 'GET',
    })
  },
  getOrderProductions(query) { // 查询订单某个产品的流转信息
    return request({
      url: '/productionRecord/open/productions' + setUrlParam(query),
      method: 'GET',
    })
  },



  backForUpdateNum(query) { // 查询订单某个产品的流转信息
    return request({
      url: '/productionRecord/open/backForUpdateNum' + setUrlParam(query),
      method: 'GET',
    })
  },



  backList(query) { // 查询订单某个产品的流转信息
    return request({
      url: '/productionRecord/open/backList' + setUrlParam(query),
      method: 'GET',
    })
  },
  backList(query) { // 查询订单某个产品的流转信息
    return request({
      url: '/productionRecord/open/backList' + setUrlParam(query),
      method: 'GET',
    })
  },




  nextProductionRecord(query) {
    return request({
      url: '/productionRecord/open/nextProductionRecord' + setUrlParam(query),
      method: 'GET',
    })
  },
  productionsWithTag(query) {
    return request({
      url: '/productionRecord/open/productionsWithTag' + setUrlParam(query),
      method: 'GET',
    })
  },
  staffFlow(query) {
    return request({
      url: '/staff/open/staff' + setUrlParam(query),
      method: 'GET',
    })
  },
  submitNew(query) {
    return request({
      url: '/productionRecord/open/submitNew',
      data: query,
      method: 'POST',
    })
  },
  submitUpdate(query) {
    return request({
      url: '/productionRecord/open/submitUpdate',
      data: query,
      method: 'POST',
    })
  },
  getCustomInfo(query) {
    return request({
      url: '/custInfo/page' + setUrlParam(query),
      method: 'GET',
    })
  },
  addOrUpdateCustom(query) {
    return request({
      url: '/custInfo/addOrUpdate',
      data: query,
      method: 'POST',
    })
  },
  deleteCustom(query) {
    return request({
      url: '/custInfo/delete' + setUrlParam(query),
      method: 'GET',
    })
  },
  toBeTransferredNum(query) {
    return request({
      url: '/productionRecord/open/toBeTransferredNum' + setUrlParam(query),
      method: 'GET',
    })
  },


}

export default api;
